#ifndef __OPERATOR_H
#define __OPERATOR_H 1

#include <token.h>

// https://zh.cppreference.com/w/c/language/operator_precedence
enum Operator : int {
  kOpNone = 0,

  kOpSelfIncSufix,
  kOpSelfDecSufix,
  kOpFuncCall,
  kOpArraySubscript,
  kOpMemberAccess,
  kOpPointer,


  kOpSelfIncPrefix,
  kOpSelfDecPrefix,
  kOpPostive,
  kOpNegative,
  kOpLogicNot,
  kOpBitNot,
  kOpTypeCast,
  kOpPtrDeref,
  kOpAddress,
  kOpSizeof,

  kOpDiv,
  kOpMult,
  kOpReminder,

  kOpAdd,
  kOpSub,

  kOpShiftLeft,
  kOpShiftRight,

  kOpGreatThan,
  kOpGreatEqual,
  kOpLessThan,
  kOpLessEqual,

  kOpEqual,
  kOpNotEqual,

  kOpBitAnd,

  kOpBitXor,

  kOpBitOr,

  kOpLogicAnd,

  kOpLogicOr,

  kOpCond,

  kOpAssign,
  kOpDivAssign,
  kOpModAssign,
  kOpMultAssign,
  kOpAddAssign,
  kOpMinusAssign,
  kOpShiftLeftAssign,
  kOpShiftRightAssign,
  kOpBitAndAssign,
  kOpBitXorAssign,
  kOpBitOrAssign,

  kOpComma,
};

enum OpType : int {
  kNoneOp = 0,
  kUnaryOp,
  kBinaryOp,
  kTernaryOp,
};

enum OpAssociative : int {
  kLeftToRight = 1,
  kRightToLeft = 2,
};

using OpPriority = int;

enum : OpPriority {
  kLowestPriority = 20,
};

Operator genOperator(TokenType token);
OpPriority operatorPriority(Operator op);
OpAssociative operatorAssociative(Operator op);
OpType operatorType(Operator op);
const char *operatorName(Operator op);




#endif // __OPERATOR_H